﻿<template>
  <div class="device-management">
    <div class="page-header">
      <h1 class="page-title gradient-text">📱 设备管理</h1>
      <p class="page-desc">联邦学习节点设备监控与管理</p>
    </div>

    <!-- 设备类型切换 - 使用自定义按钮 -->
    <div class="device-type-tabs">
      <div class="custom-tabs">
        <button 
          v-for="tab in tabs" 
          :key="tab.value"
          :class="['custom-tab', { active: currentDeviceType === tab.value }]"
          @click="currentDeviceType = tab.value"
        >
          <span class="tab-icon">{{ tab.icon }}</span>
          <span class="tab-text">{{ tab.label }}</span>
        </button>
      </div>
    </div>

    <!-- 动态加载对应设备组件 -->
    <div class="device-container">
      <component 
        :is="currentDeviceComponent" 
        :key="currentDeviceType"
        class="device-component">
      </component>
    </div>
  </div>
</template>

<script setup>
import { ref, computed } from 'vue'
import CloudDevice from '../components/CloudDevice.vue'
import EdgeDevice from '../components/EdgeDevice.vue'
import VehicleDevice from '../components/VehicleDevice.vue'

// 响应式数据
const currentDeviceType = ref('cloud')

// 标签配置
const tabs = [
  { value: 'cloud', label: '云设备', icon: '☁️' },
  { value: 'edge', label: '边缘设备', icon: '🖥️' },
  { value: 'vehicle', label: '车辆设备', icon: '🚗' }
]

// 计算属性返回对应的组件
const currentDeviceComponent = computed(() => {
  const components = {
    cloud: CloudDevice,
    edge: EdgeDevice,
    vehicle: VehicleDevice
  }
  return components[currentDeviceType.value] || CloudDevice
})

const handleDeviceTypeChange = () => {
  console.log(`切换到${currentDeviceType.value}设备`)
}
</script>

<style scoped>
.device-management {
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0c0e1a 0%, #1a1f35 50%, #0f1220 100%);
}

.page-header {
  text-align: center;
  margin-bottom: 30px;
  padding: 20px;
  width: 100%;
  max-width: 800px;
}

.page-title {
  margin: 0;
  font-size: 2.2em;
  background: linear-gradient(45deg, #00f2fe, #9d50bb);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.page-desc {
  color: rgba(255, 255, 255, 0.7);
  font-size: 1.1em;
  margin: 0;
}

.device-type-tabs {
  margin-bottom: 30px;
  text-align: center;
  width: 100%;
  max-width: 800px;
}

.device-container {
  width: 100%;
  max-width: 1200px;
  display: flex;
  justify-content: center;
}

.device-component {
  width: 100%;
}

/* 自定义标签样式 */
.custom-tabs {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.custom-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 24px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(79, 172, 254, 0.3);
  border-radius: 10px;
  color: #ffffff;
  font-size: 1.1em;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 120px;
  justify-content: center;
}

.custom-tab:hover {
  background: rgba(79, 172, 254, 0.1);
  border-color: rgba(79, 172, 254, 0.5);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(79, 172, 254, 0.2);
}

.custom-tab.active {
  background: linear-gradient(45deg, #00f2fe, #9d50bb);
  border-color: transparent;
  box-shadow: 0 4px 20px rgba(0, 242, 254, 0.3);
  transform: translateY(-2px);
}

.tab-icon {
  font-size: 1.2em;
}

.tab-text {
  color: #ffffff;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .custom-tabs {
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }
  
  .custom-tab {
    width: 200px;
  }
}
</style>